﻿<%@ Page Language="C#" MasterPageFile="~/web.master" AutoEventWireup="true" CodeBehind="branch_rollout_version_list.aspx.cs"
    Inherits="Shuba.Web.bulk_upload.branch_rollout_version_list" %>

<%@ Register Assembly="Shuba.Framework" Namespace="Shuba.Framework" TagPrefix="cc" %>
<asp:Content ID="Header1" ContentPlaceHolderID="HeaderPlaceHolder" runat="server">

    <script type="text/javascript">
		function PrintThis()
		{
			var txt = document.getElementById('<%= ddlVersion.ClientID %>').value;
			var clusterId = document.getElementById('<%= ddlCluster.ClientID %>').value;
			var regionalId = document.getElementById('<%= ddlRegion.ClientID %>').value;
			window.open("branch_rollout_version_list_excel.aspx?txtSearch=" + txt +"~"+ clusterId +"~"+ regionalId);
		}
		
        function CheckAll()
        {
            var checkVal;
            if(document.all("ButSelect").value == 'Check All')
            {
                checkVal = true;
                document.all("ButSelect").value = "Un-Check All";
            }else
            {
                checkVal = false;
                document.all("ButSelect").value = "Check All";
            }

            for (var n = 0; n < document.forms[0].length; n++)
            {
                elm = document.forms[0].elements[n];
                if (elm.type == 'checkbox')
                {
                    elm.checked = checkVal;
                }
            }
        }
        
        function konfirmasi()
        {
            var konfirmasi = confirm("Are you sure, you want to delete this record ?");
            if (konfirmasi == true)
            {
                alert("To delete this record you have to make approval");
                return true;
            }
            else
            {
                alert("you have to cancel the delete process");
                return false;
            }
        }

    </script>

</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table class="text" border="0" width="100%" cellspacing="0" cellpadding="2">
        <tr>
            <td class="text bg_content" bgcolor="#FFFFFF" align="center">
                <p>
                    &nbsp;</p>
                <table class="black" border="0" width="95%" cellspacing="0" cellpadding="0">
                    <tr>
                        <td class="title_back" align="left">
                            <table class="text" border="0" width="100%" cellspacing="0" cellpadding="0">
                                <tr>
                                    <td class="title_back2" width="2%">
                                        &nbsp;
                                    </td>
                                    <td class="title_back2 title_white" width="38%">
                                        <asp:Label ID="LabelTitle" runat="server" Text="Label"></asp:Label>
                                    </td>
                                    <td>
                                        <span class="title_right"></span>
                                    </td>
                                </tr>
                            </table>
                        </td>
                        <td class="title_back" align="right">
                            <asp:LinkButton ID="btnAdd" runat="server" PostBackUrl="branch_rollout_version_add.aspx" CssClass="black">New&nbsp;Branch&nbsp;Rollout&nbsp;Version</asp:LinkButton>&nbsp;&nbsp;
                            <asp:LinkButton ID="btnUpload" runat="server" PostBackUrl="branch_rollout_version_upload.aspx" CssClass="black">Upload&nbsp;Branch&nbsp;Rollout&nbsp;Version</asp:LinkButton>&nbsp;&nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td class="border_left bg_subtitle_white">
                            &nbsp;&nbsp;&nbsp;List
                        </td>
                        <td class="border_right bg_subtitle" align="right">
                            <%--Branch&nbsp;id&nbsp;&nbsp;<asp:TextBox ID="txtSearch" CssClass="text" runat="server"
                                Width="250px"></asp:TextBox>&nbsp;
                            <asp:Button ID="btnSearch" CssClass="buttonsmall" runat="server" Text="Search" OnClick="btnSearch_Click" />&nbsp;&nbsp;--%>
                            <input type="button" value="Export to Excel" onclick="PrintThis();" class="button" />&nbsp;&nbsp;
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" class="border">
                            <!-- class="border" -->
                            <table width="100%" class="black" border="0" cellspacing="0" cellpadding="3">
                                <tr>
                                    <td class="bg_grid" align="right">
                                        REGION
                                    </td>
                                    <td class="bg_grid2" align="left">
                                        <asp:DropDownList ID="ddlRegion" AutoPostBack="true" runat="server" Width="285px"
                                            CssClass="text" OnSelectedIndexChanged="ddlRegion_SelectedIndexChanged">
                                        </asp:DropDownList>
                                        &nbsp;<asp:Label ID="lblRegion" runat="server" Text="" Visible="false"></asp:Label> 
                                        <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator6" runat="server" ErrorMessage="&nbsp;Region is required"
                                            ControlToValidate="ddlRegion"></asp:RequiredFieldValidator>--%>
                                        &nbsp;
                                    </td>
                                </tr>
                                <tr>
                                    <td class="bg_grid" align="right">
                                        CLUSTER
                                    </td>
                                    <td class="bg_grid2" align="left">
                                        <asp:UpdatePanel ID="UpdatePanel2" runat="server">
                                            <ContentTemplate>
                                                <asp:DropDownList ID="ddlCluster" AutoPostBack="true" runat="server" Width="285px"
                                                    CssClass="text">
                                                </asp:DropDownList>
                                                &nbsp;<asp:Label ID="lblCluster" runat="server" Text="" Visible="false"></asp:Label> 
                                                <%--<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="&nbsp;Cluster is required"
                                                    ControlToValidate="ddlCluster"></asp:RequiredFieldValidator>--%>
                                                &nbsp;
                                            </ContentTemplate>
                                            <Triggers>
                                                <asp:AsyncPostBackTrigger ControlID="ddlRegion" EventName="SelectedIndexChanged" />
                                            </Triggers>
                                        </asp:UpdatePanel>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="bg_grid" align="right">
                                        VERSION
                                    </td>
                                    <td class="bg_grid2" align="left">
                                        <asp:UpdatePanel ID="UpdatePanel3" runat="server">
                                            <ContentTemplate>
                                                <asp:DropDownList ID="ddlVersion" runat="server" Width="285px" CssClass="text"></asp:DropDownList>
                                                &nbsp;<asp:Label ID="lblVersion" Text="" runat="server" Visible="false"></asp:Label>
                                            </ContentTemplate>
                                        </asp:UpdatePanel>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="bg_grid" align="right">
                                        &nbsp;
                                    </td>
                                    <td class="bg_grid2" align="left" colspan="3">
                                        <asp:Button ID="btnSearch" CssClass="buttonsmall" runat="server" Text="Search" OnClick="btnSearch_Click" />
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td class="border" colspan="2">
                            <asp:UpdatePanel ID="listPanel" runat="server">
                                <ContentTemplate>
                                    <cc:SHUBAGrid ID="gvbranch_rollout_version" runat="server" AutoGenerateColumns="False"
                                        Width="100%" DataKeyNames="BranchID,version" OnRowCommand="gvbranch_rollout_version_RowCommand"
                                        AllowPaging="True" PageSize="20" OnPageIndexChanging="gvbranch_rollout_version_PageIndexChanging"
                                        OnRowDataBound="gvbranch_rollout_version_RowDataBound" AllowSorting="True" OnSorting="gvbranch_rollout_version_Sorting">
                                        <Columns>
                                            <asp:BoundField DataField="BranchID" HeaderText="BRANCH ID" SortExpression="BranchID" ItemStyle-HorizontalAlign="Center" />
                                            <asp:BoundField DataField="BranchName" HeaderText="BRANCH NAME" SortExpression="BranchName" ItemStyle-HorizontalAlign="Left" />
                                            <asp:BoundField DataField="version" HeaderText="VERSION" SortExpression="version" ItemStyle-HorizontalAlign="Center" />                                            
                                            <asp:BoundField DataField="implementation_date" HeaderText="IMPLEMENTATION DATE" SortExpression="implementation_date" DataFormatString="{0:dd MMMM yyyy}" ItemStyle-HorizontalAlign="Center" />
                                            <asp:TemplateField HeaderText="IS ACTIVE" SortExpression="is_delete" ItemStyle-HorizontalAlign="Center">
                                                <ItemTemplate>
                                                    <%# Eval("is_delete").ToString() == "1" ? "True" : "False"%>
                                                </ItemTemplate>
                                            </asp:TemplateField>
                                            <asp:TemplateField HeaderStyle-Width="10%">
                                                <ItemTemplate>
                                                    [&nbsp;&nbsp;<asp:LinkButton ID="btnEdit" CssClass="line" runat="server" CommandName="Edit"
                                                        CommandArgument='<%#Eval("BranchID")+ "~" + Eval("version")%>'>EDIT</asp:LinkButton>&nbsp;&nbsp;]&nbsp;
                                                    [&nbsp;&nbsp;<asp:LinkButton ID="btnDelete" CssClass="line" runat="server" CommandName="Remove"
                                                        CommandArgument='<%#Eval("BranchID") + "~" + Eval("version")%>' OnClientClick="return konfirmasi();">DELETE</asp:LinkButton>&nbsp;&nbsp;]
                                                </ItemTemplate>
                                                <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                                            </asp:TemplateField>
                                        </Columns>
                                        <PagerSettings Mode="Numeric" Visible="true" />
                                        <EmptyDataTemplate>
                                            <table class="text" width="100%" cellpadding="0" cellspacing="0">
                                                <tr>
                                                    <td class="bg_grid2" align="center">
                                                        NO RECORD FOUND
                                                    </td>
                                                </tr>
                                            </table>
                                        </EmptyDataTemplate>
                                    </cc:SHUBAGrid>
                                </ContentTemplate>
                                <Triggers>
                                    <asp:AsyncPostBackTrigger ControlID="gvbranch_rollout_version" EventName="PageIndexChanging" />
                                    <asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
                                </Triggers>
                            </asp:UpdatePanel>
                        </td>
                    </tr>
        </table>
        <br />
        <!-- Error Message -->
        <table runat="server" visible="false" id="ErrBox" border="0" width="100%" cellspacing="0"
            cellpadding="2">
            <tr>
                <td class="bg_grid2" align="center">
                    <asp:Label ID="ErrMsg" runat="server" Text="" Font-Bold="true" ForeColor="Red"></asp:Label>
                </td>
            </tr>
        </table>
        <!-- End Of Error Message -->
        <br />
        <br />
        <p>
            &nbsp;</p>
        <asp:Panel ID="ApprovalPnl" Visible="false" runat="server">
            <table class="black" border="0" width="95%" cellspacing="0" cellpadding="0">
                <tr>
                    <td class="title_back" align="left" width="40%">
                        <table class="text" border="0" width="100%" cellspacing="0" cellpadding="0">
                            <tr>
                                <td class="title_back2" width="2%">
                                    &nbsp;
                                </td>
                                <td class="title_back2 title_white" width="38%">
                                    Need for Approval
                                </td>
                                <td>
                                    <span class="title_right" width="60%"></span>
                                </td>
                            </tr>
                        </table>
                    </td>
                    <td class="title_back" align="right">
                        &nbsp;&nbsp;
                    </td>
                </tr>
                <tr>
                    <td class="border" colspan="2">
                        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                            <ContentTemplate>
                                <cc:SHUBAGrid ID="ApprovalGrid" runat="server" AutoGenerateColumns="False" Width="100%"
                                    DataKeyNames="BranchID,version" AllowPaging="True" PageSize="20" OnPageIndexChanging="ApprovalGrid_PageIndexChanging"
                                    AllowSorting="True" OnSorting="gvbranch_rollout_version_Sorting">
                                    <Columns>
                                        <asp:TemplateField HeaderStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Middle"
                                            HeaderStyle-Width="10%" ItemStyle-HorizontalAlign="Center">
                                            <HeaderTemplate>
                                                <input type="button" id="ButSelect" name="ButSelect" value="Check All" class="button"
                                                    onclick="CheckAll()">
                                            </HeaderTemplate>
                                            <ItemTemplate>
                                                <asp:CheckBox ID="chkItemSelect" runat="server" />
                                            </ItemTemplate>
                                        </asp:TemplateField>
                                        <asp:BoundField DataField="BranchID" HeaderText="BRANCH ID" SortExpression="BranchID"
                                            ItemStyle-HorizontalAlign="Left" />
                                        <asp:BoundField DataField="version" HeaderText="VERSION" SortExpression="version"
                                            ItemStyle-HorizontalAlign="Left" />
                                        <asp:BoundField DataField="implementation_date" HeaderText="IMPLEMENTATION DATE"
                                            SortExpression="implementation_date" ItemStyle-HorizontalAlign="Center" />
                                        <%--<asp:BoundField DataField="is_delete" HeaderText="IS DELETE" SortExpression="is_delete"
                                            ItemStyle-HorizontalAlign="Center" />--%>
                                        <asp:BoundField DataField="entry_by" HeaderText="ENTRY BY" SortExpression="entry_by"
                                            ItemStyle-HorizontalAlign="Left" />
                                        <asp:BoundField DataField="entry_date" HeaderText="ENTRY DATE" SortExpression="entry_date"
                                            ItemStyle-HorizontalAlign="Left" />
                                        <asp:BoundField DataField="update_by" HeaderText="UPDATE BY" SortExpression="update_by"
                                            ItemStyle-HorizontalAlign="Left" />
                                        <asp:BoundField DataField="update_date" HeaderText="UPDATE DATE" SortExpression="update_date"
                                            ItemStyle-HorizontalAlign="Left" />
                                        <asp:BoundField DataField="ActType" HeaderText="ACTION TYPE" SortExpression="ActType"
                                            ItemStyle-HorizontalAlign="Left" />
                                    </Columns>
                                    <PagerSettings Mode="Numeric" Visible="true" />
                                    <EmptyDataTemplate>
                                        <table class="text" width="100%" cellpadding="0" cellspacing="0">
                                            <tr>
                                                <td class="bg_grid2" align="center">
                                                    NO RECORD FOUND
                                                </td>
                                            </tr>
                                        </table>
                                    </EmptyDataTemplate>
                                </cc:SHUBAGrid>
                            </ContentTemplate>
                            <Triggers>
                                <asp:AsyncPostBackTrigger ControlID="btnSearch" EventName="Click" />
                            </Triggers>
                        </asp:UpdatePanel>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" align="left" class="bg_footer" height="30">
                        &nbsp;
                        <asp:Button ID="btnApprove" Text="Approve" runat="server" CssClass="button" OnClick="btnApprove_Click"
                            OnClientClick="return ApproveValidate();" />
                        <asp:Button ID="btnApproveAll" Text="Approve All" runat="server" CssClass="button"
                            OnClick="btnApproveAll_Click" OnClientClick="return confirm('Are you sure, you want to approve all record(s) ?')" />
                        <asp:Button ID="btnReject" Text="Reject" runat="server" CssClass="button" OnClick="btnReject_Click"
                            OnClientClick="return RejectValidate();" />
                        <asp:Button ID="btnRejectAll" Text="Reject All" runat="server" CssClass="button"
                            OnClick="btnRejectAll_Click" OnClientClick="return confirm('Are you sure, you want to reject all record(s) ?')" />
                    </td>
                </tr>
            </table>
        </asp:Panel>
        </td> </tr>
    </table>
</asp:Content>
